package com.example.homeworkmutualevaluation.Service;

import com.example.homeworkmutualevaluation.Dao.SCDao;
import com.example.homeworkmutualevaluation.Entity.SC;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class SCService {
    @Resource
    private SCDao scDao;
    public boolean inCourse(String sphone, String cno) {
        return scDao.findBySphoneAndCno(sphone, cno) != null;
    }
    public boolean select(String sphone, String cno) {
        if (inCourse(sphone, cno)) return false;
        else return scDao.insert(sphone, cno) > 0;
    }
    public boolean delete(String sphone, String cno) {
        return scDao.delete(sphone, cno) > 0;
    }
    public List<SC> findAll() {
        return scDao.findAll();
    }
    public int countByCno(String cno) {
        return scDao.countByCno(cno);
    }
}
